<template> 
<!-- 新增修改用户 -->
 <el-dialog
    :model-value="visible"
    :title="title"
    width="800"
    :before-close="handleClose"
    :close-on-click-modal="false"
  >
  <el-form :model="form" label-width="auto">
    <el-row :gutter="20">
        <el-col :span="12">
            <el-form-item label="单位名称">
                <el-select
                    v-model="form.comCode"
                    placeholder="请选择"
                    @change="handleChangeComCode"
                    filterable
                    clearable
                >
                    <el-option
                        v-for="item in comOptions"
                        :key="item.comCode"
                        :label="item.comName"
                        :value="item.comCode"
                    />
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="部门名称">
                <el-select
                    v-model="form.depCode"
                    placeholder="请选择"
                    filterable
                    clearable
                >
                    <el-option
                        v-for="item in depOptions"
                        :key="item.depCode"
                        :label="item.depName"
                        :value="item.depCode"
                    />
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="职务名称">
                <el-select
                    v-model="form.dutCode"
                    placeholder="请选择"
                    filterable
                    clearable
                >
                    <el-option
                        v-for="item in dutOptions"
                        :key="item.dutCode"
                        :label="item.dutName"
                        :value="item.dutCode"
                    />
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="角色名称">
                <el-select
                    v-model="form.rolCode"
                    placeholder="请选择"
                    filterable
                    clearable
                >
                    <el-option
                        v-for="item in rolOptions"
                        :key="item.rolCode"
                        :label="item.rolName"
                        :value="item.rolCode"
                    />
                </el-select>
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="登录账号">
                <el-input v-model="form.userCode" disabled placeholder="请输入" />
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="用户姓名">
                <el-input v-model.trim="form.userName" :maxlength="20" placeholder="请输入" />
            </el-form-item>
        </el-col>
        <el-col :span="12">
            <el-form-item label="联系电话">
                <el-input v-model.trim="form.userPhone" :maxlength="20" placeholder="请输入" />
            </el-form-item>
        </el-col>
       
        <el-col :span="12">
            <el-form-item label="是否在职">
                <el-radio-group v-model="form.userFlag">
                    <el-radio :value="0">离职</el-radio>
                    <el-radio :value="1">在职</el-radio>
                </el-radio-group>
            </el-form-item>
        </el-col>
    </el-row>
  </el-form>
    <template #footer>
      <div class="dialog-footer">
        <el-button @click="handleClose">取消</el-button>
        <el-button type="primary" @click="handleConfirm">
          确定
        </el-button>
      </div>
    </template>
  </el-dialog>
</template>

<script setup>
import { watch, ref } from 'vue'
import { ElMessage } from 'element-plus'
// import { apiUserCode, apiAddUser } from '@/api/user'


let props = defineProps({
  visible: {
    type: Boolean,
    default: false
  },
  entry: String,
  data: {
    type: Object,
    default: () => {}
  }
})
let emit = defineEmits(['close', 'confirm'])

let form = ref({
  comCode: '',
  depCode: '',
  dutCode: '',
  rolCode: '',
  userCode: '',
  userName: '',
  userPhone: '',
  userFlag: 1
})
let title = ref('')

// 取消
const handleClose = () => {

  emit('close')
}
// 确定
// const handleConfirm = async () => {

//   const res = await apiAddUser({
//     ...form.value
//   })
//   if(res) {
//     ElMessage.success('操作成功')
        
//     emit('confirm')
//   }
// }
</script>

<style lang="scss" scoped>

</style>